import numpy  as np
import pandas as pd
import talib as ta

eps = 1e-8

def signal(*args):
    # ZhenZhangRatio 振幅 涨幅的比率
    # https://bbs.quantclass.cn/thread/9454

    df = args[0]
    n = args[1]
    factor_name = args[2]

    # 涨跌幅std，振幅的另外一种形式
    df['Zhang'] = df['close'].pct_change()
    df['zhen'] = df['high']/df['low'] - 1
    df[factor_name] = df['zhen']/(df['Zhang'] + eps)

    return df